{% extends 'app01/site.html' %}

{% block left_content %}

       <div class="col-md-2">
                {% block files %}
{#                    <h4>#}
{#                        <a href="/app01/site/{{ blog.userinfo.username }}/file?back_url={{ request.get_full_path_info }}"#}
{#                           class=" btn btn-success btn-block">{{ blog.userinfo.username }}共享文件#}
{#                            <span class="glyphicon glyphicon-floppy-save"></span></a>#}
{#                    </h4>#}

                {% endblock %}


{#                筛选框的代码，#}
                {% load my_tag %} <!--加载inclusion_tag函数-->
                {% left_menu username request%} <!-- 调用该html，传递参数 -->

            </div>

{% endblock %}

{% block content %}
    <div class="col-md-10">
    <h3 class="text-center">共享笔记</h3>
        {% for file in files %}
            <div class="media">
                <div class="media-left">
                    <a href="#">
                        <img class="media-object" src="/media/{{ blog.userinfo.avatar }}" alt="..." height="64">
                    </a>
                </div>
                <div class="media-body">
                    <h3 class="media-heading"><a href="/app01/preview_file?file_id={{ file.pk }}&url={{ request.get_full_path_info }}">{{ file.name }}</a>
                    </h3>
                    {{ file.desc }}
                </div>
                <div class="pull-right"> 上传时间：{{ file.create_time }} &nbsp;&nbsp;&nbsp;
                    <span class="glyphicon glyphicon-cloud-download"></span>下载数({{ file.number }})
                    &nbsp;&nbsp;&nbsp;作者 <span class="glyphicon glyphicon-user"></span>：{{ file.userinfo.username }}</div>
            </div>
            <hr>

        {% endfor %}

{#    分页器的显示#}
     {# 分页显示 #}
    <div class="pager">
         <nav aria-label="Page navigation">
          <ul class="pagination">
                {{ page_html}}
          </ul>
        </nav>
    </div>

    </div>
{% endblock %}

{% block js %}
    <script>
    //关注的ajax
     $('#focu_btn_id').click(function () {
        $.ajax({
            url:'/app01/focu/user/',
            type:'get',
            data:{'my_name':'{{ request.user.username }}','focu_name':'{{ blog.userinfo.username }}','url':'{{ request.get_full_path_info }}'},
            success:function (array) {
                alert(array.msg)
            }
        })

    })

    //修改密码的ajax
     $('#id_editer').on('click', function () {
            let old_pwd = $('#id_old_pwd').val()
            let new_pwd = $('#id_new_pwd').val()
            let confirm_pwd = $('#id_confirm_pwd').val()
            $.ajax({
                url: '/app01/set_password/',
                type: 'post',
                data: {
                    'old_pwd': old_pwd,
                    'new_pwd': new_pwd,
                    'confirm_pwd': confirm_pwd,
                    //'csrfmiddlewaretoken':{{ csrf_token }}
                },
                success: function (array) {
                    if (array.code === 1000) {
                        {#parent.location.href='/app01/login/'#}
                        //刷新当前url
                        alert('修改密码成功，重新登录')
                        window.location.reload()
                    } else {
                        $('#error').text(array.msg)
                    }

                }
            })

        });

    </script>
{% endblock %}
